function rest=srcf(n,term,type)

unimesh=(0:1/n:1)';

if(strcmp(type,'naive'))
% srchdbyu{1}{1}=@(x)-x.*sin(x)   +cos(x);  srchdbyu{1}{2}=@(x) x.*exp(-x) -exp(-x);   srchdbyu{1}{3}=@(x) -2*x.*cos(x) -sin(x);   srchdbyu{1}{4}=@(x)3*x.*exp(x) +exp(x);
% srchdbyu{2}{1}=@(x)-2*x.*sin(x) +cos(x);  srchdbyu{2}{2}=@(x) x.*exp(-x) -2*exp(-x); srchdbyu{2}{3}=@(x) -x.*cos(x)   -2*sin(x); srchdbyu{2}{4}=@(x)3*x.*exp(x) +exp(x);
% srchdbyu{3}{1}=@(x)-3*x.*sin(x) +2*cos(x);srchdbyu{3}{2}=@(x) x.*exp(-x) -exp(-x);   srchdbyu{3}{3}=@(x) -3*x.*cos(x) -sin(x);   srchdbyu{3}{4}=@(x)3*x.*exp(x) +2*exp(x);
% srchdbyu{4}{1}=@(x)-2*x.*sin(x) +2*cos(x);srchdbyu{4}{2}=@(x) x.*exp(-x) -exp(-x);   srchdbyu{4}{3}=@(x) -2*x.*cos(x) -2*sin(x); srchdbyu{4}{4}=@(x)2*x.*exp(x) +3*exp(x);
srchdbyu{1}{1}=@(x)-7*x.*sin(x) +3*cos(x);  srchdbyu{1}{2}=@(x) 6*x.*exp(-x) -2*exp(-x);   srchdbyu{1}{3}=@(x) -5*x.*cos(x) -sin(x);   srchdbyu{1}{4}=@(x)4*x.*exp(x) +4*exp(x);
srchdbyu{2}{1}=@(x)-6*x.*sin(x) +2*cos(x);  srchdbyu{2}{2}=@(x) 5*x.*exp(-x) -exp(-x); srchdbyu{2}{3}=@(x) -4*x.*cos(x)   -4*sin(x); srchdbyu{2}{4}=@(x)3*x.*exp(x) +3*exp(x);
srchdbyu{3}{1}=@(x)-5*x.*sin(x) +cos(x);srchdbyu{3}{2}=@(x) 4*x.*exp(-x) -4*exp(-x);   srchdbyu{3}{3}=@(x) -3*x.*cos(x) -3*sin(x);   srchdbyu{3}{4}=@(x)2*x.*exp(x) +2*exp(x);
srchdbyu{4}{1}=@(x)-4*x.*sin(x) +4*cos(x);srchdbyu{4}{2}=@(x) 3*x.*exp(-x) -3*exp(-x);   srchdbyu{4}{3}=@(x) -2*x.*cos(x) -2*sin(x); srchdbyu{4}{4}=@(x)x.*exp(x) +exp(x);

tmp =zeros(n-1,term);
for ii=1:term
    f{ii}=@(x) 0;
    for jj=1:term
        f{ii}=@(x) f{ii}(x)+srchdbyu{ii}{jj}(x);
    end
    tmp(:,ii)=f{ii}(unimesh(2:n));
    [bdcorL,bdcorR]=bdcorrector(ii,n,term,type);
    tmp(1,ii)  =tmp(1,ii)  +bdcorL;
    tmp(n-1,ii)=tmp(n-1,ii)+bdcorR;
end

rest=reshape(tmp,[(n-1)*term,1]);


elseif(strcmp(type,'polychaos'))
    f{1}=@(x) 0+x-x;
    tmp =zeros(n-1,term);
    [bdcorL,bdcorR]=bdcorrector(1,n,term,type);
    tmp(1,1)  =tmp(1,1)  +bdcorL;
    tmp(n-1,1)=tmp(n-1,1)+bdcorR;
    f{2}=@(x) 0+x-x;
    f{3}=@(x) 0+x-x;
    f{4}=@(x) 0+x-x;
    rest=reshape(tmp,[(n-1)*term,1]);
end
    